using System.Linq;
using Xunit;

namespace GearUp.Crawler.Tests
{
    public class LorebookDocumentTests
    {
        [Fact]
        public void ShouldParseHtml()
        {
            var document = new LorebookDocument(Resource1.CategoryItemsHtml);
            Assert.NotNull(document);
        }

        [Fact]
        public void ShouldReturnLinks()
        {
            var document = new LorebookDocument(Resource1.CategoryItemsHtml);
            var links = document.LinksInArticleBodyDiv();
            Assert.True(links.Count() > 0);
        }

        [Fact]
        public void ShouldDetectAnOfficialLorebookEntry()
        {
            var document = new LorebookDocument(Resource1.ArmourPageHtml);
            var itemDetails = document.OfficialLorebookEntry();
            Assert.NotNull(itemDetails);
        }

        [Fact]
        public void ShouldReturnNullWhenNoOfficialLorebookEntryExists()
        {
            var document = new LorebookDocument(Resource1.CategoryItemsHtml);
            var itemDetails = document.OfficialLorebookEntry();
            Assert.Null(itemDetails);
        }

        [Fact]
        public void ShouldDetectEditLink()
        {
            var document = new LorebookDocument(Resource1.ArmourPageHtml);
            var actual = document.EditLink();
            Assert.NotNull(actual);
        }

        [Fact]
        public void ShouldReturnNullWhenThereIsNoEditLink()
        {
            var document = new LorebookDocument(Resource1.CategoryItemsHtml);
            var actual = document.EditLink();
            Assert.Null(actual);
        }

    }
}